<?php
	require_once(realpath(dirname(__FILE__)) . "/Baseobj.class.php");
	require_once(realpath(dirname(__FILE__)) . "/Autorisation_modules.class.php");

	class Modules extends Baseobj{

		// Les types de plugins
		const PAIEMENT = 1;
		const TRANSPORT = 2;
		const CLASSIQUE = 3;
		const FILTRE = 4;

		var $id;
		var $nom;
		var $type;
		var $actif;
		var $classement;
		var $xml;

		var $activable;

		const TABLE="modules";
		var $table=self::TABLE;

		var $bddvars = array("id", "nom", "type", "actif", "classement");

		function __construct($id = 0){
			parent::__construct();

			if($id > 0)
 			  $this->charger_id($id);
		}

		function charger($nom){
			if($this->getVars("select * from $this->table where nom=\"$nom\"")){
				return 1;
			}

			return 0;
		}

		function charger_id($id){
			if($this->getVars("select * from $this->table where id=\"$id\"")){
				return 1;
			}

			return 0;
		}

		function est_autorise(){
			if($_SESSION['util']->profil == "1")
				return 1;

			$verif = new Autorisation_modules();
			if($verif->charger($this->id, $_SESSION['util']->id) && $verif->autorise)
				return 1;

			return 0;

		}
	}


?>